<template>
  <div>
    <button @click="getSend()"> get 发送</button>
    <button @click="postSend()"> post 发送</button>
<!--    <input type="text" v-model="aurhor">-->
<!--    <li v-for="item in goodsList">-->
<!--      {{ item.author }}-->
<!--    </li>-->
  </div>
</template>
<script>
export default {
  data() {
    return {
      goodsList: [],
      aurhor: ""
    }
  },
  created() {
    this.getSend()
  },
  methods: {


    postSend() {

      //    private String sname;			//名字
      // private String goodsno;			//编号
      // private String author;			//作者
      const queryObj = {
        sname:"测试",
        goodsno:"123231",
        author:"xm"
      }

      this.$axios.post("http://localhost:8082/goods/addGoods",queryObj)
      .then(res=>{
            if (res.status === 200) {
              console.log(res.data)
            }
      })
    },

    getSend() {

      const queryObj = {
        // id: 1,
        // author: "",
        // name: "书本"
      }

      // 可以这么写
      this.$axios({
        method: 'get',
        url: 'http://localhost:8082/goods/findGoods',
        params: queryObj
      }).then(res => {
        if (res.status === 200) {
          console.log(res)
          this.goodsList = res.data
          this.aurhor = res.data[0].author
        }

      });
    }
  }
}
</script>


